#include "JkWindow.h"

JkWindow::JkWindow(HINSTANCE hInstance) {
	this->hInstance;
}

JkWindow::~JkWindow() {
}

HINSTANCE JkWindow::GetHIstance() {
	return this->hInstance;
}

HWND JkWindow::GetHwnd() {
	return this->hwnd;
}

VOID JkWindow::SetClassName(LPCWSTR className) {
	this->className = className;
}

VOID JkWindow::SetRect(RECT rect) {
	this->rect;
}

int JkWindow::RegisterWnd(WNDPROC pWndProc) {
	WNDCLASSEX cls = { 0 };
	cls.cbSize = sizeof(cls);
	cls.cbClsExtra = 0;
	cls.cbWndExtra = 0;
	cls.hIcon = NULL;
	cls.style = CS_HREDRAW | CS_VREDRAW;
	cls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	cls.hCursor = LoadCursor(NULL, IDC_ARROW);
	cls.lpfnWndProc = pWndProc;
	cls.hInstance = hInstance;
	cls.lpszMenuName = NULL;
	cls.lpszClassName = className;
	return RegisterClassEx(&cls);
}

HWND JkWindow::CreateWnd(RECT rect, int nCmdShow, LPCWSTR wndName) {
	AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, false);
	HWND hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, className,
		wndName,
		WS_OVERLAPPEDWINDOW,
		rect.left,
		rect.top,
		rect.right,
		rect.bottom,
		0, 0, hInstance, 0);
	this->hwnd = hwnd;
	return hwnd;
}

VOID JkWindow::ShowWnd() {
	ShowWindow(hwnd, SW_NORMAL);
	UpdateWindow(hwnd);
	MSG msg = { 0 };
	while (GetMessage(&msg, NULL, 0, 0)) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
}